<?php
/**
 * 添加省
 * 通过par_id为 0 的添加为省 
 */

include('./config/db.php');
$pgdb = new PGDB;

// 2.接受前端发送过来的数据
if(isset($_POST) && !empty($_POST['province'])){
    $province = trim($_POST['province']);
    // 3.构建SQL语句
    $sql = "insert into public.management_t(name,par_id) VALUES('$province',0);";
    $res = @$pgdb->query($sql);
    // 4.返回结果
    if(!$res){
       die(json_encode(array('Code'=>0x000002,'Msg'=>'添加省失败')));
    }
    die(json_encode(array('Code'=>0x000000,'Msg'=>'添加省成功')));
}else{
    die(json_encode(array('Code'=>0x000001,'Msg'=>'没有数据上传')));
}